﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "CheckBoxGroupDefinitionReference.h"
#include "ControlDefinitionChangeEvent.h"
#include "GUiBaseInterfaceEnums.h"
#include "ICheckBoxGroupHandler.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h"

namespace gcmp
{
CheckBoxGroupDefinitionReference::CheckBoxGroupDefinitionReference(CheckBoxGroupDefinition* pCheckBoxGroupDefinition)
    :m_pControlDefinition(pCheckBoxGroupDefinition)
{

}

CheckBoxGroupDefinitionReference::~CheckBoxGroupDefinitionReference()
{

}

std::wstring CheckBoxGroupDefinitionReference::GetId() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pControlDefinition, L"", L"m_pCheckBoxGroupDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetId();
}

std::wstring CheckBoxGroupDefinitionReference::GetCaption() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pControlDefinition, L"", L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetCaption();
}

std::wstring CheckBoxGroupDefinitionReference::GetTooltip() const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pControlDefinition, L"", L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetTooltip();
}

bool CheckBoxGroupDefinitionReference::AddCheckBox(const std::wstring& id, const std::wstring& caption, const std::wstring& tooltip, CheckState checkState)
{
     DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
     return m_pControlDefinition->AddCheckBox(id, caption, tooltip, checkState);
}

bool CheckBoxGroupDefinitionReference::InsertCheckBox(const std::wstring& beforeId, const std::wstring& id, const std::wstring& caption, const std::wstring& tooltip, CheckState checkState)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->InsertCheckBox(beforeId, id, caption, tooltip, checkState);
}

bool CheckBoxGroupDefinitionReference::DeleteCheckBox(const std::wstring& id)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->DeleteCheckBox(id);
}

void CheckBoxGroupDefinitionReference::DeleteAllCheckBoxes()
{
    DBG_WARN_AND_RETURN_VOID_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->DeleteAllCheckBoxes();
}

std::vector<const ICheckBoxDefinition*> CheckBoxGroupDefinitionReference::GetAllCheckBoxes() const
{
    std::vector<const ICheckBoxDefinition*> res;
    DBG_WARN_AND_RETURN_UNLESS(m_pControlDefinition, res, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetAllCheckBoxes();
}

gcmp::CheckState CheckBoxGroupDefinitionReference::GetCheckState(const std::wstring& id, bool* pOk /*= nullptr*/) const
{
    DBG_WARN_AND_RETURN_UNLESS(m_pControlDefinition, CheckState::Unchecked, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetCheckState(id, pOk);
}

bool CheckBoxGroupDefinitionReference::SetCheckState(const std::wstring& id, CheckState checkState)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->SetCheckState(id, checkState);
}

gcmp::ICheckBoxGroupEvent* CheckBoxGroupDefinitionReference::GetEvent() const
{
    DBG_WARN_AND_RETURN_NULLPTR_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->GetEvent();
}

gcmp::IControlDefinitionChangeEvent* CheckBoxGroupDefinitionReference::GetControlDefinitionChangeEvent() const
{
    if (m_pControlDefinition)
    {
        return m_pControlDefinition->GetControlDefinitionChangeEvent();
    }
    return nullptr;
}

bool CheckBoxGroupDefinitionReference::IsVisible() const
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->IsVisible();
}

bool CheckBoxGroupDefinitionReference::IsEnabled() const
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->IsEnabled();
}

bool CheckBoxGroupDefinitionReference::SetEnabled(const std::wstring& id, bool enabled)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->SetEnabled(id, enabled);
}

bool CheckBoxGroupDefinitionReference::SetVisible(const std::wstring& id, bool visible)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->SetVisible(id, visible);
}

bool CheckBoxGroupDefinitionReference::SetControlHandler(OwnerPtr<ICheckBoxGroupHandler> pControlHandler)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(pControlHandler, L"pControlHandler为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->SetControlHandler(TransferOwnership(pControlHandler));
}

bool CheckBoxGroupDefinitionReference::BlockControlHandler(bool needBlock)
{
    DBG_WARN_AND_RETURN_FALSE_UNLESS(m_pControlDefinition, L"m_pControlDefinition为空",L"GDMPLab",L"2024-03-30");
    return m_pControlDefinition->BlockControlHandler(needBlock);
}

}   // end namespace gcmp
